|
|
|
|
|
|
|
LISTING 3.3. FILEOPEN.TXTGIVING USERS THE ABILITY TO OPEN ANY TEXT FILE ON THE COMPUTER. |
|
|
|
 |
|
|
|
|
1: Private Sub mnuFileOpen_Click()
2: Dim sFile As String
3:
4: With dlgCommonDialog
5: .DialogTitle = Open
6: .CancelError = False
7: ToDo: set the flags and attributes of the common dialog control
8: .Filter = Text Files (*.txt)¦*.txt
9: .ShowOpen
10: If Len(.filename) = 0 Then
11: Exit Sub
12: End If
13: sFile = .filename
14: End With
15: Open sFile For Input As #1
16: lblTitle(1).Caption = Edit Mode - & UCase(sFile)
17: txtInput.Text = Input(LOF(1), 1)
18: Close #1
19:
20: End Sub |
|
|
|
|
|
|
|
|
Now execute the application. Double-click each of the two selections in the tree list and see how you can work with the data in the TextBox control (see Figure 3.17). At the same time, choose File, Open from the menu and select any other text file on your computer to see how it's displayed in the text box. Of course, you can also add code for many menu options and buttons. |
|
|
|
|
|